%%%-------------------------------------------------------------------
%%% @author Administrator
%%% @copyright (C) 2021, <COMPANY>
%%% @doc
%%% @end
%%%-------------------------------------------------------------------
-module(server_sup).

-behaviour(supervisor).

-export([start_link/1, init/1]).

-spec(start_link(Type :: term()) -> {ok, Pid :: pid()} | ignore | {error, Reason :: term()}).
start_link(Type) ->
    supervisor:start_link({local, ?MODULE}, ?MODULE, [Type]).

init([Type]) ->
    {ok, {
        {one_for_one, 50, 1}    %% 1秒内重启50次，超过则会关闭节点
        , [
            {env, {env, start_link, []}, transient, 10000, worker, [env]}
            , {make_code, {make_code, start_link, []}, transient, 10000, worker, [make_code]}
            , {sql_conn_mgr, {sql_conn_mgr, start_link, []}, transient, 10000, worker, [sql_conn_mgr]}
            , {server_mgr, {server_mgr, start_link, [Type]}, transient, 10000, worker, [server_mgr]}
        ]}}.
